package process

import (
	"dmsv/session"
	"dmsv/uuid"
	"fmt"
	"github.com/beego/beego/v2/core/logs"
	"i-hea/utils/httplib"
)

const (
	NotifyNotice = "notice"
	NotifyVerify = "verify"
)

var (
	gVosAddr        = "119.23.185.33:6532"
	gCallBack       = ""
	gMediaDir       = "/data/media/numbers/"
	gNotifyDir      = "/data/qmy/notify/"
	gNotifyPrefix   = "94"
	gVerifyPrefix   = "84"
	gCallbackPrefix = "64"
	gPrefixEnable   = true
)

func Init(url string, dsid int) {

	gCallBack = url

	httpClient = httplib.NewHttpClient()

	uuidWorker, err := uuid.NewIdWorker(int64(dsid))
	if err != nil {
		panic(err)
	}

	//400 业务初始化
	callInInit()

	//直拨初始化
	callcenterInit()

	gDsid = dsid
	gUUIDCreate = uuidWorker

}

func SetPreix(notify, verify, callback string, enable bool) {
	gNotifyPrefix = notify
	gVerifyPrefix = verify
	gCallbackPrefix = callback
	gPrefixEnable = enable

	logs.Info("set notify prefix : %v", notify)
	logs.Info("set verify prefix : %v", verify)
	logs.Info("set callback prefix : %v", callback)

	logs.Info("enable prefix : %v", gPrefixEnable)
}

func HangUpTheCall(appId, callId string) error {

	_, ok := gEterpriceHandle[appId]
	if ok {
		return session.HangUpTheCall(callId)
	} else {
		logs.Error("cannot find enterprise:%v", appId)
		return fmt.Errorf("appId不存在")
	}
}
